import uuid

from CloudEngine.core.VTActor import VTActor
from Connector.client import res_success
from service.utils.cell_type_helper import cell_type_to_cn


class CmdMeshList:
    name = "mesh_list"
    id = uuid.uuid4()

    def __init__(self, service, Params, Tag, Type):
        self.service = service
        self.params = Params
        self.tag = Tag
        self.type = Type

    async def execute(self):
        ac: VTActor = self.service.get_first_actor()
        keys = ac.loader.type_map.keys()
        res = []
        for key in keys:
            res.append({"key": key, "name": cell_type_to_cn(key)})
        await res_success(self.tag, self.type, {"meshes": res})
